package com.zhengwl.study.aop;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public  class LogInvocationHandler implements InvocationHandler {

	private Object target;

	public LogInvocationHandler(Object target) {
		super();
		this.target = target;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		// 执行原有逻辑
		Object rev = method.invoke(target, args);
		// 执行织入的日志，你可以控制哪些方法执行切入逻辑
		if (method.getName().equals("doWork")) {
			System.out.println("记录日志");
		}
		return rev;
	}

}
